package com.yaodian100.ec.announcement.service;

import java.util.ArrayList;
import java.util.List;

import com.yaodian100.core.common.exception.CoreException;
import com.yaodian100.core.common.service.DomainService;
import com.yaodian100.ec.announcement.entity.Announcement;

/**
 * 
 * @author apple.chang
 * 
 */
public interface AnnouncementService extends DomainService<Announcement> {

	public static final String ANNOUNCEMENT_TYPE_MEMBER_MESSAGE = "MEMBER_MESSAGE";
	public static final String SHOW_SEQ_SORT_CLAUSE = "showSeqAsNumber asc";
	public static final String[] DEFAULT_SORT_FOR_HQL = { "startDate desc", SHOW_SEQ_SORT_CLAUSE, "modifyDate desc" };

	/**
	 * 儲存公告
	 * 
	 * @param entity
	 * @return
	 * @throws CoreException
	 */
	public Announcement saveOrUpdateAnnouncement(Announcement entity) throws CoreException;

	/**
	 * 取得公告
	 * 
	 * @param crit
	 * @return
	 * @throws CoreException
	 */
	public List<Announcement> getAnnouncementList(String[] sortOrder) throws CoreException;

	/**
	 * 取得目前可顯示公告
	 * 
	 * @param size all:-1
	 * @return
	 * @throws CoreException
	 */
	public List<Announcement> getVisibleAnnouncementList(int size) throws CoreException;

	/**
	 * 刪除公告
	 * 
	 * @param announcementId
	 * @return
	 */
	public Announcement deleteAnnouncement(String announcementId) throws CoreException;

	/**
	 * 取得entity
	 * 
	 * @param announcementId
	 * @return
	 * @throws CoreException
	 */
	public Object[] getAnnouncementById(String announcementId) throws CoreException;

	/**
	 * 依 id 取得取得目前正在發佈期間內的公告。如果沒有 id 相符且正在發佈期間內的公告就回傳 null。
	 * 
	 * @param announcementId
	 * @return
	 * @throws CoreException
	 */
	public Announcement getVisibleAnnouncementById(String announcementId) throws CoreException;

	/**
	 * 取得目前可顯示公告+限制类别
	 * 
	 * @param type
	 * @param size
	 * @return
	 * @throws CoreException
	 */
	public List<Announcement> getVisibleAnnouncementList(ArrayList<String> type, int size) throws CoreException;

	/**
	 * 取得目前可顯示會員訊息
	 * 
	 * @param size 最多筆數
	 * @return
	 */
	public List<Announcement> getMemberMessageList();

}